package com.cn.xiaonuo.slbfinances.slborders.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cn.xiaonuo.common.entity.BusinessMessage;
import com.cn.xiaonuo.dbs.core.annotation.DataSource;
import com.cn.xiaonuo.slbfinances.slborders.entity.SlRechargeOrder;
import com.cn.xiaonuo.slbfinances.slborders.mapper.CmRechargeMapper;
import com.cn.xiaonuo.slbfinances.slborders.mapper.SlRechargeOrderMapper;
import com.cn.xiaonuo.slbfinances.slborders.service.ICoverageRechargeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class CoverageRechargeServiceImpl extends ServiceImpl<CmRechargeMapper, String> implements ICoverageRechargeService {

    @Autowired
    private CmRechargeMapper cmRechargeMapper;
    @Autowired
    private SlRechargeOrderMapper slRechargeOrderMapper;


    @Override
    @DataSource(name = "jyb_soole_data_hn")
    public BusinessMessage dailyPayOrderRefund(List list) throws Exception {
        BusinessMessage<Object> message = new BusinessMessage<>();
        try {
            for (Object rechargeId : list) {
                SlRechargeOrder slRechargeOrder = slRechargeOrderMapper.selectById(Integer.valueOf(rechargeId+""));
                slRechargeOrder.setPaymentState(2);
                slRechargeOrder.seteRechargeState("9");
                slRechargeOrder.setUpdatedAt(new Date());
                slRechargeOrder.setRefundAt(new Date());
                slRechargeOrderMapper.updateById(slRechargeOrder);
            }
            message.setMessage("操作成功");
            message.setSuccess(true);
            message.setCode("200");
            return message;
        } catch (Exception e) {
            e.printStackTrace();
        }
        message.setMessage("查询失败");
        message.setSuccess(false);
        message.setCode("-1");
        return message;
    }

}
